<template>
  <div class="home-view">
    <div class="navigator" :class="{ active: showTabs }">
      <h1 class="logo">
        <router-link to="/">
          <span>mk-ui</span>
        </router-link>
      </h1>
      <div class="tabs">
        <router-link to="/" class="tab right" exact>
          <span>首页</span>
        </router-link>
        <router-link to="/docs" class="tab right">
          <span>文档</span>
        </router-link>
        <router-link to="/example" class="tab right">
          <span>示例</span>
        </router-link>
      </div>
      <span class="toggle-nav" @click="toggleNav">
        <img src="./nav.svg">
      </span>
    </div>
    <div class="router-view">
      <router-view></router-view>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      showTabs: false
    }
  },
  methods: {
    toggleNav() {
      this.showTabs = !this.showTabs
    }
  }
}
</script>
<style lang="scss" >
$fontsize-large-xx: 20px;
@import '~assets/stylesheets/main';
.home-view {
  height: 100%;
  padding-top: 70px;
  box-sizing: border-box;
  transition: all 250ms ease;

  .router-view {
    height: 100%;
  }
}
.navigator {
  height: 70px;
  line-height: 70px;
  margin-top: -70px;
  background-color: $mkc;
  transition: all 0.3s ease;
  overflow: hidden;

  .toggle-nav {
    display: none;

    @media screen and (max-width: 960px) {
      display: flex;
      position: absolute;
      left: 10px;
      top: 0;
      width: 40px;
      height: 70px;
      align-items: center;
      justify-content: center;
    }

    &:active {
      opacity: 0.6;
    }

    img {
      width: 20px;
      height: 20px;
    }
  }

  &.active {
    height: 255px;
  }

  .logo {
    float: left;
    background-color: $vice;

    @media screen and (max-width: 960px) {
      float: none;
      background-color: transparent;
      text-align: center;
    }

    a {
      display: block;
      padding: 0 28px;
      color: white;
      font-size: $fontsize-large-xx;

      @media screen and (max-width: 960px) {
        display: inline-block;
      }

      &::before {
        display: inline-block;
        width: 36px;
        height: 29px;
        margin-right: 10px;
        vertical-align: middle;
      }
    }
  }

  .tabs {
    float: right;
    padding: 0 30px;

    @media screen and (max-width: 960px) {
      float: none;
      padding: 0;
      border-top: solid 1px rgba(255, 255, 255, 0.5);
    }

    .tab {
      display: inline-block;
      margin: 0 10px;

      @media screen and (max-width: 960px) {
        display: block;
        line-height: 45px;
        margin: 0 20px;
      }

      color: white;
      transition: color 0.2s;

      &:hover {
        color: $vice;
      }
    }

    .router-link-active {
      color: $vice;
    }
  }
}
</style>
